<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="info"></div>
    <script>
        var info = document.getElementById('info');
        setInterval(function() {
            // 现在的日期
            var nd = new Date();
            // 目标日期六 表示7月
            var td = new Date(2022, 6, 8);
            // 毫秒差
            var diff = td - nd;
            // 把Diff换算为天小时分钟秒
            // 换算为多少天, 除以一天的总毫秒
            var day = parseInt(diff / (1000 * 60 * 60 * 24));
            var hours = parseInt(diff % (1000 * 60 * 60 * 24) / (1000 * 60 * 60));
            var minutes = parseInt(diff % (1000 * 60 * 60) / (1000 * 60));
            var seconds = parseInt(diff % (1000 * 60 * 60) % (1000 * 60) / 1000);

            info.innerText = day + '天' + hours + '时' + minutes + '分' + seconds + '秒';
        }, 1000)
    </script>
</body>

</html>